package fg.objects;

import org.newdawn.slick.Image;

import fg.Consts;
import fg.sprite.Sprite;

public class Lure extends Sprite {

	protected Rod rod;
	protected float velocityX = 0f;
	protected float velocityY = 0f;
	protected float frictionAir = 0.99f;
	protected float frictionWater = 0.8f;
	
	public Lure(Rod rod, Image image) {
		super(image);
		this.rod = rod;
	}
	
	public void update(int delta) {
		if (rod.lureAttached != false) return;
		x += velocityX;
		y += velocityY;
		velocityX *= frictionAir;
		
		velocityY *= frictionAir;
		if (!isInWater()) {
			velocityY += 0.02f;
			if (velocityY > 2f) {
				velocityY = -1f;
			}
		}
	}
	
	public void setVelocity(float vx, float vy) {
		this.velocityX = vx;
		this.velocityY = vy;
	}
	
	public boolean isInWater() {
		return (y > Consts.WATER_Y);
	}
	
}
